package whatHandlers;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class whatStatsRegex {
	// Regex Classes
	private whatCDLogin WCL;
	
	private Pattern PATTERN;
	private Matcher MATCHER;

	// Internal Values
	private String UPLOADEDStr;
	private String DOWNLOADEDStr;
	private String RATIO;
	private String REQRATIO;

	private double uploadedDBL_;
	private double downloadedDBL_;
	private String _uploadedSuffix;
	private String _downloadedSuffix;

	// Static regex strings

	private final String UploadedRawRegex = "Uploaded: [0-9]+\\.[0-9]+.[M,G,T,P]B";

	private final String DownloadedRawRegex = "Downloaded: [0-9]+\\.[0-9]+.[M,G,T,P]B";

	private final String RequiredRatioRawRegex = "Required ratio: [0-9]+\\.[0-9]+";

	private final String FindUserIDRawRegex = "\"user\\.php\\?id=162790\" class=\"username";
	private final String FindConciseUserIDRegex = "user\\.php\\?id=[0-9]+";

	public whatStatsRegex() {

	}

	public String FindUploadedString(String RawHTML) {
		String Tmp = WCL.getPage(RawHTML);
		
		
		PATTERN = Pattern.compile(UploadedRawRegex);
		MATCHER = PATTERN.matcher(RawHTML);
		MATCHER.find();
		return MATCHER.group();
	}

	public String FindDownloadedString(String RawHTML) {
		PATTERN = Pattern.compile(DownloadedRawRegex);
		MATCHER = PATTERN.matcher(RawHTML);
		MATCHER.find();
		return MATCHER.group();
	}

	public String FindReqRatioString(String RawHTML) {
		PATTERN = Pattern.compile(RequiredRatioRawRegex);
		MATCHER = PATTERN.matcher(RawHTML);
		MATCHER.find();
		return MATCHER.group(0);
	}

}
